package com.design.pattern.creational.builder;

/**
 * <p>
 * 建造者模式demo
 * </p>
 *
 * @author RenQiQiang 2019/01/31 10:48
 */
public class Course {

    private String title;

    private String startTime;

    private String endTime;

    private String price;

    public Course(CourseBuilder builder){
        this.title = builder.title;
        this.startTime = builder.startTime;
        this.endTime = builder.endTime;
        this.price = builder.price;
    }

    @Override
    public String toString() {
        return "Course{" +
                "title='" + title + '\'' +
                ", startTime='" + startTime + '\'' +
                ", endTime='" + endTime + '\'' +
                ", price='" + price + '\'' +
                '}';
    }

    public static class CourseBuilder{
        private String title;

        private String startTime;

        private String endTime;

        private String price;

        public CourseBuilder builderTitle(String title){
            this.title = title;
            return this;
        }
        public CourseBuilder builderStartTime(String startTime){
            this.startTime = startTime;
            return this;
        }
        public CourseBuilder builderEndTime(String endTime){
            this.endTime = endTime;
            return this;
        }
        public CourseBuilder builderPrice(String price){
            this.price = price;
            return this;
        }

        public Course builder(){
            return new Course(this);
        }
    }
}
